|
|
|
|
|
|
|
Here, you want to put the current quarter into the location where the X characters are located. Therefore, if the date is Jan. 1, 2000, you want the string to be displayed in the DateTimePicker control like this: |
|
|
|
 |
|
|
|
|
Jan Sat 2000 (Qtr 1) |
|
|
|
|
|
|
|
|
To accomplish this, you need to run the control and have it fire the FormatSize event. This event is only called one time and is used to return the largest size of the format youre going to return into the location where the X characters are in the CustomFormat property. In this case, you know that youll return five characters (QTR 1). Therefore, you would write the FormatSize() event as follows: |
|
|
|
 |
|
|
|
|
Private Sub DTPicker6_FormatSize(_
ByVal CallbackField As String, _
Size As Integer) Size = 5 End Sub |
|
|
|
|
|
|
|
|
The FormatSize() event accepts an argument called CallbackField. This is the field with the X characters in it. This event also passes in a Size argument by reference. You set this Size argument to the size of the data that will be placed into the CallbackField argument. |
|
|
|
|
|
|
|
|
After the FormatSize event is called once, every time you change to a new date, the Format() event will be called again. This is where you change the FormattedString argument thats passed in. This FormattedString argument is then placed into the DateTimePicker control at the location where the X characters were located. Heres an example: |
|
|
|
 |
|
|
|
|
Private Sub DTPicker6_Format(_
ByVal CallbackField As String, _
FormattedString As String)
Select Case Month(DTPicker6.Value)
Case 1, 2, 3 FormattedString = "Qtr 1" Case 4, 5, 6
FormattedString = "Qtr 2"
Case 7, 8, 9
FormattedString = "Qtr 3"
Case 10, 11, 12
FormattedString = "Qtr 4"
End Select
End Sub |
|
|
|
|
|